package com.sihai.ehr.model.biz;

import javax.persistence.*;

@Entity
@DiscriminatorValue("audit_contract_sign")
public class ContractSignAuditing extends AuditingBase {

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "contract_sign_id")
	private ContractSign contractSign;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "contract_sign_zz_id")
	private ContractSignZz contractSignZz;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "contract_sign_rt_id")
	private ContractSignRt contractSignRt;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "contract_sign_rtt_id")
	private ContractSignRtt contractSignRtt;

	public ContractSign getContractSign() {
		return contractSign;
	}

	public void setContractSign(ContractSign contractSign) {
		this.contractSign = contractSign;
	}

	public ContractSignZz getContractSignZz() {
		return contractSignZz;
	}

	public void setContractSignZz(ContractSignZz contractSignZz) {
		this.contractSignZz = contractSignZz;
	}

	public ContractSignRt getContractSignRt() {
		return contractSignRt;
	}

	public void setContractSignRt(ContractSignRt contractSignRt) {
		this.contractSignRt = contractSignRt;
	}

	public ContractSignRtt getContractSignRtt() {
		return contractSignRtt;
	}

	public void setContractSignRtt(ContractSignRtt contractSignRtt) {
		this.contractSignRtt = contractSignRtt;
	}

	public EmployeeinfoBase getEmployee() {
		if (contractSign != null) {
			return contractSign.getEmployeeinfoBase();
		}
		if (contractSignZz != null) {
			return contractSignZz.getEmployeeinfoBase();
		}
		if (contractSignRt != null) {
			return contractSignRt.getEmployeeinfoBase();
		}
		if (contractSignRtt != null) {
			return contractSignRtt.getEmployeeinfoBase();
		}
		return null;
	}

	public Long getTargetId() {
		if (contractSign != null) {
			return contractSign.getId();
		}
		if (contractSignZz != null) {
			return contractSignZz.getId();
		}
		if (contractSignRt != null) {
			return contractSignRt.getId();
		}
		if (contractSignRtt != null) {
			return contractSignRtt.getId();
		}
		
		return null;
	}
}
